using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using SpoonCore2.Client;
using SpoonCore2.Message;
using SpoonCore2.Message.Filter;
using SpoonCore2.Message.Header;

namespace SpoonCore2.Service
{
	public delegate void OnSendDataHandler(IService sender, SpoonIdentifier id, IMessage message);
	public delegate void OnSendDataHandlerInfo(IService sender, ClientInfo info, IMessage message);
	public delegate void OnSendDataHandlerEndpoint(IService sender, IPEndPoint endpoint, IMessage message);

	public enum ServiceStatus { Stoped, Running }

	public interface IService : IDisposable
	{
		event OnSendDataHandler OnSendData;
		event OnSendDataHandlerInfo OnSendDataInfo;
		event OnSendDataHandlerEndpoint OnSendDataEndpoint;
		void Send(SpoonIdentifier id, IMessage message);
		void Send(ClientInfo info, IMessage message);
		void Send(IPEndPoint endpoint, IMessage message);
		SpoonIdentifier Id { get; }
		MessageHandler Handler { get; }
		ServiceManager Manager { get; }
		void Init();
		void Start();
		void Stop();
		ServiceStatus Status { get;}
		void SetManager(ServiceManager manager);
		void Receive(ClientInfo info, BinaryReader reader, IList<IMessageOption> options, IList<IMessageFilterInfo> filters);
	}
}